1. Configuració inicial i càrrega del fitxer GDF¶

Aquesta secció configura l'entorn per a la càrrega de dades EEG des d'un fitxer GDF. Inicialment, obtenim el directori actual de treball i, a continuació, construïm el camí absolut al fitxer GDF. Si el fitxer existeix, es carrega utilitzant la biblioteca MNE i es mostra la informació de les dades carregades.

In [ ]:
import os
import mne

# Get the current working directory
current_directory = os.getcwd()

# Move up one directory to the parent directory
parent_directory = os.path.dirname(current_directory)

# Define the relative path to the GDF file
relative_gdf_file_path = 'dataset/B0101T.gdf'

# Build the absolute path to the GDF file
gdf_file_path = os.path.join(parent_directory, relative_gdf_file_path)

# Check if the file exists
if os.path.exists(gdf_file_path):
    # Load the data using MNE
    raw_data = mne.io.read_raw_gdf(gdf_file_path, preload=True)
    # Print the information about the channels
    raw_data.info
else:
    "GDF file not found or could not be loaded."
Extracting EDF parameters from /Users/superjordi/repos/uoc/TFG/exp1_bciciv_ds_b/dataset/B0101T.gdf...
GDF file detected
Setting channel info structure...
Could not determine channel type of the following channels, they will be set as EEG:
EEG:C3, EEG:Cz, EEG:C4, EOG:ch01, EOG:ch02, EOG:ch03
Creating raw.info structure...
Reading 0 ... 604802  =      0.000 ...  2419.208 secs...
/var/folders/lt/rksts1mn7p7f78615mlf9g7h0000gn/T/ipykernel_18743/3059637042.py:19: RuntimeWarning: Highpass cutoff frequency 100.0 is greater than lowpass cutoff frequency 0.5, setting values to 0 and Nyquist.
  raw_data = mne.io.read_raw_gdf(gdf_file_path, preload=True)

2. Extracció i visualització d'informació de canals i esdeveniments¶

Aquesta secció extreu i mostra la informació dels canals i els esdeveniments de les dades EEG. Incloent els noms dels canals, els tipus de canals i la informació dels esdeveniments anotats. Això proporciona una visió general dels components de les dades EEG abans de la seva anàlisi detallada.

In [ ]:
# Extracting the channel names and types from the data
channel_info = raw_data.info['chs']
channel_names = [ch['ch_name'] for ch in channel_info]
channel_types = [ch['kind'] for ch in channel_info]

# Extracting event information
events, event_id = mne.events_from_annotations(raw_data)

# Displaying channel names, types, and event information
channel_names, channel_types, event_id
Used Annotations descriptions: ['1023', '1077', '1078', '1079', '1081', '276', '277', '32766', '768', '769', '770']
Out[ ]:
(['EEG:C3', 'EEG:Cz', 'EEG:C4', 'EOG:ch01', 'EOG:ch02', 'EOG:ch03'],
 [2 (FIFFV_EEG_CH),
  2 (FIFFV_EEG_CH),
  2 (FIFFV_EEG_CH),
  2 (FIFFV_EEG_CH),
  2 (FIFFV_EEG_CH),
  2 (FIFFV_EEG_CH)],
 {'1023': 1,
  '1077': 2,
  '1078': 3,
  '1079': 4,
  '1081': 5,
  '276': 6,
  '277': 7,
  '32766': 8,
  '768': 9,
  '769': 10,
  '770': 11})

3. Inspecció visual de les dades EEG i EOG¶

Aquí, realitzem una inspecció visual de les dades EEG i EOG. Es mostren segments curts de dades per a una avaluació ràpida de la seva qualitat i per identificar possibles artefactes. Aquesta anàlisi visual és un pas important abans del processament més detallat de les dades.

In [ ]:
import matplotlib.pyplot as plt

# Plotting a short segment of the EEG and EOG data for visual inspection
plot_duration = 10  # in seconds
start_time = 100  # start time for the plot, in seconds

# Plot EEG data
raw_data.copy().pick('eeg').plot(start=start_time, duration=plot_duration, scalings='auto', title='EEG Data')

# Check if EOG channels are present and plot EOG data
channel_types = [mne.channel_type(raw_data.info, idx) for idx in range(raw_data.info['nchan'])]
if 'eog' in channel_types:
    raw_data.copy().pick('eog').plot(start=start_time, duration=plot_duration, scalings='auto', title='EOG Data')
else:
    "No EOG channels found."

plt.show()
No description has been provided for this image

4. Creació d'epochs i inspecció visual de les mateixes¶

En aquesta secció, es creen epochs basades en esdeveniments de motor imagery i es realitza una inspecció visual d'unes quantes d'aquestes epochs. Les epochs són segments temporals de dades EEG al voltant d'esdeveniments específics, i la seva visualització ajuda a comprendre les dinàmiques temporals associades a diferents tipus d'activitat cerebral.

In [ ]:
# Let's take a closer look at the events and their IDs
events_extracted = list(event_id.keys())
events_extracted.sort()

# Display the sorted list of extracted event descriptions and their corresponding IDs
events_extracted, [event_id[ev] for ev in events_extracted]

from mne import Epochs, pick_types

# Define the event IDs for left hand (class 1) and right hand (class 2) motor imagery
# We use the event IDs as they are represented in the data (10 for left hand, 11 for right hand)
event_id_motor_imagery = {'Left Hand': 10, 'Right Hand': 11}

# Define the time interval around the events for epoching (e.g., from -1 to 4 seconds)
tmin, tmax = -1, 4

# Pick EEG channels for epoching
picks = pick_types(raw_data.info, eeg=True, eog=False)

# Create epochs for motor imagery events
epochs = Epochs(raw_data, events, event_id_motor_imagery, tmin, tmax, proj=True, picks=picks, baseline=None, preload=True)

epochs.plot(n_epochs=10, n_channels=len(picks)).show()  # Plotting a few epochs for inspection)

# Display the shape of the epochs array
epochs
Not setting metadata
120 matching events found
No baseline correction applied
0 projection items activated
Using data from preloaded Raw for 120 events and 1251 original time points ...
0 bad epochs dropped
No description has been provided for this image
/var/folders/lt/rksts1mn7p7f78615mlf9g7h0000gn/T/ipykernel_18743/1502128185.py:23: UserWarning: FigureCanvasAgg is non-interactive, and thus cannot be shown
  epochs.plot(n_epochs=10, n_channels=len(picks)).show()  # Plotting a few epochs for inspection)
Out[ ]:
Number of events 120
Events Left Hand: 60
Right Hand: 60
Time range -1.000 – 4.000 s
Baseline off

5. Filtratge de les epochs per a anàlisi específica de bandes de freqüència:¶

Aquesta secció aplica un filtre de banda passa a les èpoques per centrar-se en bandes de freqüència específiques que són rellevants per a l'anàlisi de tipus motor imagery. El filtratge ajuda a reduir el soroll i millora la claredat dels senyals per a anàlisis posteriors.

In [ ]:
# Applying band-pass filter to the data
low_freq, high_freq = 1, 40  # Low and high cut-off frequencies

# Applying the filter to the EEG data
filtered_epochs = epochs.copy().filter(low_freq, high_freq, fir_design='firwin')

# Plotting the filtered data for a few epochs for visual inspection
filtered_epochs.plot(n_epochs=10, n_channels=len(picks))
Setting up band-pass filter from 1 - 40 Hz

FIR filter parameters
---------------------
Designing a one-pass, zero-phase, non-causal bandpass filter:
- Windowed time-domain design (firwin) method
- Hamming window with 0.0194 passband ripple and 53 dB stopband attenuation
- Lower passband edge: 1.00
- Lower transition bandwidth: 1.00 Hz (-6 dB cutoff frequency: 0.50 Hz)
- Upper passband edge: 40.00 Hz
- Upper transition bandwidth: 10.00 Hz (-6 dB cutoff frequency: 45.00 Hz)
- Filter length: 825 samples (3.300 s)

[Parallel(n_jobs=1)]: Done  17 tasks      | elapsed:    0.0s
[Parallel(n_jobs=1)]: Done  71 tasks      | elapsed:    0.0s
[Parallel(n_jobs=1)]: Done 161 tasks      | elapsed:    0.0s
[Parallel(n_jobs=1)]: Done 287 tasks      | elapsed:    0.1s
[Parallel(n_jobs=1)]: Done 449 tasks      | elapsed:    0.1s
[Parallel(n_jobs=1)]: Done 647 tasks      | elapsed:    0.2s
No description has been provided for this image
Out[ ]:
No description has been provided for this image

6. Aplicació de l'Anàlisi de Components Independents (ICA)¶

L'ICA és utilitzada aquí per identificar i eliminar artefactes com parpelleigs o moviments musculars. Aquesta secció mostra com inicialitzar i ajustar ICA, i com visualitzar els components per a la identificació d'artefactes. És una tècnica clau en el preprocessament de dades EEG per a obtenir senyals més nets.

In [ ]:
from mne.preprocessing import ICA

# Número de components per a ICA
n_components = len(filtered_epochs.ch_names)

# Inicialitza i ajusta ICA
ica = ICA(n_components=n_components, random_state=97, max_iter=800)
ica.fit(filtered_epochs)

# Traça els components ICA (les fonts)
ica.plot_sources(filtered_epochs, show_scrollbars=True)

# Guarda el gràfic si és necessari
# ica.plot_sources(filtered_epochs).savefig('ica_sources_plot.png')

"""
from itertools import combinations

n_ica_components = len(ica.ch_names)

# Limit per al nombre de components a excloure en cada prova
max_excluded = 2

# Prepara els epochs originals per a la comparació
original_epochs = filtered_epochs.copy()

# Bucle per a provar totes les combinacions possibles
for n in range(max_excluded + 1):
    for components_to_exclude in combinations(range(n_ica_components), n):
        # Exclou els components seleccionats
        ica.exclude = list(components_to_exclude)

        # Aplica ICA als epochs filtrats
        cleaned_epochs = ica.apply(original_epochs.copy())

        # Visualitza els senyals nets
        print(f"Provant amb components exclosos: {components_to_exclude}")
        cleaned_epochs.plot(n_epochs=10, n_channels=len(original_epochs.ch_names))

La combinació on s'elimina les components 0,1 es la que millors resultats dóna, per tant, la utilitzarem
"""
# Prepara els epochs originals per a la comparació
original_epochs = filtered_epochs.copy()

# Exclou els components seleccionats
ica.exclude = [0, 1]

# Aplica ICA als epochs filtrats
cleaned_epochs = ica.apply(original_epochs.copy())

# Visualitza els senyals nets
cleaned_epochs.plot(n_epochs=10, n_channels=len(original_epochs.ch_names))
Fitting ICA to data using 6 channels (please be patient, this may take a while)
Selecting by number: 6 components
Fitting ICA took 1.0s.
Not setting metadata
120 matching events found
No baseline correction applied
0 projection items activated
No description has been provided for this image
Applying ICA to Epochs instance
    Transforming to ICA space (6 components)
    Zeroing out 2 ICA components
    Projecting back using 6 PCA components
No description has been provided for this image
Out[ ]:
No description has been provided for this image

7. Extracció de característiques utilitzant la potència espectral¶

En aquesta secció, ens concentrem en l'extracció de característiques a partir de les bandes de freqüència alfa i beta. Utilitzem la potència espectral com a mètode d'extracció, que és crucial per a l'anàlisi de les dades de tipus motor imagery. Aquestes característiques seran utilitzades posteriorment per a la classificació.

In [ ]:
import numpy as np

# Defineix les bandes de freqüència
freq_bands = {'alpha': (8, 13),
              'beta': (13, 30)}

# Calcula la PSD per a tots els epochs
psd = cleaned_epochs.compute_psd(fmin=5, fmax=40, method='welch')
freqs = psd.freqs
psd_data = psd.get_data()

# Inicialitza una llista per emmagatzemar les característiques
features = []

# Itera sobre els psd_data (un array per cada epoch)
for psd_epoch in psd_data:
    # Inicialitza un diccionari per a les característiques d'aquest epoch
    epoch_features = {}

    # Calcula la potència mitjana en cada banda de freqüència
    for band, (fmin, fmax) in freq_bands.items():
        # Troba els índexs de freqüència dins de la banda
        freq_mask = (freqs >= fmin) & (freqs <= fmax)

        # Mitjana de la potència espectral dins de la banda
        mean_band_power = np.mean(psd_epoch[:, freq_mask], axis=1)
        epoch_features[band] = mean_band_power

    features.append(epoch_features)

# `features` ara conté les característiques de potència espectral per a cada epoch
features
Effective window size : 5.004 (s)
Out[ ]:
[{'alpha': array([4.39895663e-13, 4.15453276e-13, 2.90050292e-13, 1.27058431e-13,
         1.95796570e-13, 1.69039082e-13]),
  'beta': array([1.06697180e-13, 1.03277291e-13, 1.75339989e-13, 1.07734075e-13,
         6.84496989e-14, 1.06352971e-13])},
 {'alpha': array([1.10710923e-13, 4.75545108e-13, 2.57731203e-13, 8.25510799e-14,
         1.19093650e-13, 1.51466599e-13]),
  'beta': array([9.96866652e-14, 9.35422199e-14, 1.38009676e-13, 8.09408392e-14,
         5.85834304e-14, 1.19525574e-13])},
 {'alpha': array([2.08210664e-13, 2.20000280e-13, 1.16681232e-13, 1.30585873e-13,
         1.04720804e-13, 1.68331393e-13]),
  'beta': array([1.31904803e-13, 1.54571441e-13, 1.32049844e-13, 1.04413669e-13,
         8.29225157e-14, 9.48594444e-14])},
 {'alpha': array([1.44549158e-13, 3.94358684e-13, 2.44394158e-13, 1.39161571e-13,
         1.13319870e-13, 1.30750637e-13]),
  'beta': array([1.01171777e-13, 1.12252264e-13, 1.84659925e-13, 7.81596006e-14,
         6.18988692e-14, 1.00999086e-13])},
 {'alpha': array([2.38759932e-13, 7.22132257e-13, 3.60165856e-13, 1.43596734e-13,
         2.26969487e-13, 1.45718412e-13]),
  'beta': array([1.23311196e-13, 1.42147826e-13, 9.97252617e-14, 7.04277752e-14,
         7.02459303e-14, 1.27325471e-13])},
 {'alpha': array([3.65403367e-13, 1.19925707e-12, 6.83663307e-13, 1.61360389e-13,
         3.30428091e-13, 2.66725923e-13]),
  'beta': array([1.10392922e-13, 1.27391004e-13, 1.43143161e-13, 8.05729176e-14,
         6.00002823e-14, 8.75430506e-14])},
 {'alpha': array([1.93132603e-13, 2.07136293e-13, 2.74516541e-13, 1.66543155e-13,
         1.09150492e-13, 1.24483359e-13]),
  'beta': array([7.47456046e-14, 8.04893797e-14, 7.51443603e-14, 7.28736222e-14,
         4.18176262e-14, 7.93665781e-14])},
 {'alpha': array([4.00499211e-13, 1.05430429e-12, 7.76797420e-13, 2.38651494e-13,
         3.46079646e-13, 2.15764742e-13]),
  'beta': array([7.43022885e-14, 1.64855397e-13, 1.76346123e-13, 7.39822479e-14,
         5.14945016e-14, 1.03618275e-13])},
 {'alpha': array([2.04846733e-13, 2.85149552e-13, 2.03943916e-13, 8.62251287e-14,
         1.28847546e-13, 2.09307954e-13]),
  'beta': array([8.05700228e-14, 1.12956500e-13, 1.37190413e-13, 6.78709962e-14,
         5.20096786e-14, 8.17235368e-14])},
 {'alpha': array([2.38406890e-13, 7.21061053e-13, 3.30302816e-13, 1.30197350e-13,
         2.05634632e-13, 1.98931625e-13]),
  'beta': array([1.24140781e-13, 1.11435434e-13, 1.24729708e-13, 7.45053474e-14,
         6.87069948e-14, 1.14837404e-13])},
 {'alpha': array([3.34726146e-13, 1.71904161e-12, 5.20887734e-13, 2.68644022e-13,
         4.12355842e-13, 1.82655203e-13]),
  'beta': array([1.00680689e-13, 1.21811774e-13, 1.32073770e-13, 8.94261438e-14,
         5.97449568e-14, 7.11473988e-14])},
 {'alpha': array([1.95043221e-13, 4.57886128e-13, 2.59023231e-13, 1.39212734e-13,
         1.26630634e-13, 1.46365765e-13]),
  'beta': array([9.82529742e-14, 1.47638965e-13, 1.68712975e-13, 8.42924172e-14,
         6.78575839e-14, 9.51692403e-14])},
 {'alpha': array([1.59250227e-13, 4.42545239e-13, 2.66187429e-13, 9.34286573e-14,
         1.29083669e-13, 1.19921555e-13]),
  'beta': array([9.11350553e-14, 1.03749273e-13, 1.25418399e-13, 1.12344865e-13,
         5.38098228e-14, 1.15378552e-13])},
 {'alpha': array([1.90719149e-13, 7.08216868e-13, 4.48001599e-13, 2.29763102e-13,
         2.04635060e-13, 1.72403223e-13]),
  'beta': array([1.17879068e-13, 1.77218363e-13, 1.43771067e-13, 6.90262090e-14,
         7.42344481e-14, 1.05836911e-13])},
 {'alpha': array([2.42678546e-13, 6.75228081e-13, 2.57637689e-13, 1.49774637e-13,
         2.01035463e-13, 2.49940097e-13]),
  'beta': array([1.10788340e-13, 1.20166085e-13, 1.35242943e-13, 6.45100419e-14,
         6.73323621e-14, 8.98677398e-14])},
 {'alpha': array([3.05452876e-13, 1.24930129e-12, 4.89293270e-13, 1.36728905e-13,
         2.88445282e-13, 2.44150830e-13]),
  'beta': array([1.00494924e-13, 1.38421542e-13, 1.23759195e-13, 9.57822658e-14,
         6.36413793e-14, 9.94811389e-14])},
 {'alpha': array([3.37059389e-13, 4.96743406e-13, 1.91261696e-13, 1.67964328e-13,
         2.01894229e-13, 3.04930336e-13]),
  'beta': array([9.24915156e-14, 1.11066295e-13, 1.26805863e-13, 8.43267192e-14,
         5.55694290e-14, 1.10127701e-13])},
 {'alpha': array([4.00973820e-13, 7.96657537e-13, 3.78857916e-13, 3.52239995e-13,
         3.13773508e-13, 2.61561549e-13]),
  'beta': array([1.97295003e-13, 1.53978971e-13, 2.36397730e-13, 1.04339476e-13,
         1.18404210e-13, 1.45165036e-13])},
 {'alpha': array([1.49252729e-13, 2.96908335e-13, 1.81977048e-13, 8.62267669e-14,
         1.03967376e-13, 1.08324275e-13]),
  'beta': array([1.24659809e-13, 1.15355097e-13, 1.49680367e-13, 8.91105928e-14,
         7.33775758e-14, 1.27949588e-13])},
 {'alpha': array([1.78611345e-13, 5.52416118e-13, 1.43898217e-13, 8.01088390e-14,
         1.43783391e-13, 1.54134963e-13]),
  'beta': array([1.41342862e-13, 1.31131096e-13, 1.18170236e-13, 7.12020728e-14,
         7.99776095e-14, 8.81909329e-14])},
 {'alpha': array([5.51092235e-13, 7.05971287e-13, 3.06204878e-13, 2.26379922e-13,
         3.61790665e-13, 3.44628144e-13]),
  'beta': array([7.88376538e-14, 8.14740639e-14, 1.17738259e-13, 5.60572969e-14,
         4.17157818e-14, 9.44926407e-14])},
 {'alpha': array([1.83725530e-13, 3.11044187e-13, 2.90624849e-13, 7.07060444e-14,
         1.24953663e-13, 2.26889508e-13]),
  'beta': array([9.97650181e-14, 1.03148227e-13, 1.02889784e-13, 1.08218126e-13,
         5.30534636e-14, 1.18666501e-13])},
 {'alpha': array([9.68632381e-13, 4.85250281e-13, 5.52505697e-13, 3.58985638e-13,
         5.06339825e-13, 3.28827981e-13]),
  'beta': array([2.16206267e-13, 1.64446866e-13, 1.73707044e-13, 1.27452438e-13,
         1.23972470e-13, 1.39505327e-13])},
 {'alpha': array([2.35128357e-13, 9.45901617e-13, 3.75224588e-13, 1.09024963e-13,
         2.28152700e-13, 2.28935019e-13]),
  'beta': array([1.11076837e-13, 1.29261603e-13, 1.42963837e-13, 8.37940974e-14,
         6.76722641e-14, 1.08158171e-13])},
 {'alpha': array([1.84187098e-13, 6.74475080e-13, 1.58530261e-13, 1.57293661e-13,
         1.71003503e-13, 1.29985847e-13]),
  'beta': array([8.49724667e-14, 1.12014472e-13, 1.21482631e-13, 7.09471150e-14,
         5.23091513e-14, 7.91966435e-14])},
 {'alpha': array([1.73044611e-13, 3.23525218e-13, 2.12567287e-13, 1.03778267e-13,
         1.15890634e-13, 1.18856512e-13]),
  'beta': array([1.09526032e-13, 9.43650395e-14, 9.87022780e-14, 8.04224148e-14,
         5.97570448e-14, 1.14469146e-13])},
 {'alpha': array([2.56579084e-13, 4.69160836e-13, 4.57842927e-13, 9.34724705e-14,
         1.54272708e-13, 1.18525053e-13]),
  'beta': array([8.95171390e-14, 9.19373380e-14, 8.88569353e-14, 8.04703724e-14,
         5.28817848e-14, 8.62481148e-14])},
 {'alpha': array([1.63131175e-13, 7.24652122e-13, 7.09070771e-13, 7.63745235e-14,
         1.62120998e-13, 2.18615381e-13]),
  'beta': array([1.22705567e-13, 1.01025811e-13, 1.42537665e-13, 7.56292594e-14,
         6.59462082e-14, 1.02966470e-13])},
 {'alpha': array([1.61118282e-13, 6.93726384e-13, 2.36734279e-13, 1.10924227e-13,
         1.72996847e-13, 1.55376782e-13]),
  'beta': array([8.69140202e-14, 1.18106024e-13, 1.17979264e-13, 6.68288404e-14,
         5.35721911e-14, 1.19337130e-13])},
 {'alpha': array([4.57240600e-13, 6.68896268e-13, 4.75251800e-13, 2.23847449e-13,
         2.99682707e-13, 2.65939288e-13]),
  'beta': array([1.53406938e-13, 1.14119131e-13, 1.01123528e-13, 9.79742355e-14,
         7.81111309e-14, 1.48476663e-13])},
 {'alpha': array([2.09067001e-13, 3.28759277e-13, 1.94350551e-13, 9.31714776e-14,
         1.27920028e-13, 9.26145221e-14]),
  'beta': array([1.47550387e-13, 1.13060295e-13, 1.36975575e-13, 8.56081072e-14,
         7.79217573e-14, 1.22878038e-13])},
 {'alpha': array([2.87251375e-13, 7.82133719e-13, 2.44627325e-13, 1.75998499e-13,
         2.32981843e-13, 1.24541360e-13]),
  'beta': array([1.27284961e-13, 1.28758041e-13, 1.01731264e-13, 6.95973352e-14,
         6.40561745e-14, 1.17194486e-13])},
 {'alpha': array([2.05123177e-13, 1.02016925e-12, 6.51508567e-13, 1.68663230e-13,
         2.68194568e-13, 2.54774786e-13]),
  'beta': array([1.27275831e-13, 8.09593266e-14, 1.15373652e-13, 7.23943276e-14,
         5.69014612e-14, 1.03934063e-13])},
 {'alpha': array([1.75275345e-13, 5.37690592e-13, 1.70830163e-13, 1.04077368e-13,
         1.36140913e-13, 2.10405279e-13]),
  'beta': array([1.26770118e-13, 1.05303962e-13, 1.04890212e-13, 9.07825008e-14,
         6.71366939e-14, 9.86435674e-14])},
 {'alpha': array([2.24880927e-13, 1.93937208e-13, 1.78436483e-13, 1.44682380e-13,
         1.05684176e-13, 1.58198256e-13]),
  'beta': array([1.19077572e-13, 1.43487180e-13, 9.88788613e-14, 9.19505598e-14,
         7.34955880e-14, 1.02083666e-13])},
 {'alpha': array([3.17193945e-13, 5.51324269e-13, 2.63627202e-13, 1.87574571e-13,
         2.42912914e-13, 1.92852321e-13]),
  'beta': array([1.03933677e-13, 1.05639554e-13, 1.17650437e-13, 7.43876739e-14,
         5.80515660e-14, 1.12015786e-13])},
 {'alpha': array([1.94950467e-13, 3.44651202e-13, 7.34465624e-13, 1.92791264e-13,
         1.53959442e-13, 1.14087202e-13]),
  'beta': array([9.22359721e-14, 1.35216495e-13, 1.42677941e-13, 7.51394630e-14,
         5.91250748e-14, 1.33792310e-13])},
 {'alpha': array([2.40981598e-13, 6.36813871e-13, 1.47437913e-12, 1.83425670e-13,
         2.76989865e-13, 1.73289376e-13]),
  'beta': array([1.02578405e-13, 1.12508864e-13, 1.46058220e-13, 8.04782847e-14,
         5.97097520e-14, 1.03246794e-13])},
 {'alpha': array([3.51239173e-13, 4.35206372e-13, 1.66105695e-13, 1.95960469e-13,
         1.94618737e-13, 2.97557135e-13]),
  'beta': array([1.11513895e-13, 9.91085390e-14, 9.04273080e-14, 6.06378521e-14,
         5.73933615e-14, 9.17638362e-14])},
 {'alpha': array([2.16622116e-13, 6.04689228e-13, 6.63005655e-13, 2.04821859e-13,
         2.16461586e-13, 9.32726721e-14]),
  'beta': array([1.17824541e-13, 1.17390422e-13, 1.55667715e-13, 8.06961661e-14,
         7.44880064e-14, 1.00134100e-13])},
 {'alpha': array([3.45193901e-13, 6.31837318e-13, 3.36312351e-13, 2.25385174e-13,
         2.78814600e-13, 1.51098283e-13]),
  'beta': array([1.11533175e-13, 1.19748233e-13, 9.15745534e-14, 1.12899147e-13,
         6.37081117e-14, 1.28683049e-13])},
 {'alpha': array([3.41613739e-13, 9.41587968e-13, 2.83435242e-13, 1.61379330e-13,
         2.99576129e-13, 2.17694708e-13]),
  'beta': array([1.34520706e-13, 9.74116087e-14, 1.25773893e-13, 7.57654000e-14,
         6.82104858e-14, 1.22434340e-13])},
 {'alpha': array([2.85447889e-13, 4.04369811e-13, 2.46166704e-13, 1.22942538e-13,
         1.79329797e-13, 2.22431351e-13]),
  'beta': array([1.25695917e-13, 1.07345134e-13, 1.28883945e-13, 6.75548572e-14,
         6.64762580e-14, 1.04458619e-13])},
 {'alpha': array([1.84965077e-13, 8.05332340e-13, 2.32696965e-13, 1.44359419e-13,
         1.85245042e-13, 1.60639763e-13]),
  'beta': array([1.37246210e-13, 1.37453345e-13, 1.13231347e-13, 8.29101907e-14,
         7.79774541e-14, 9.64295605e-14])},
 {'alpha': array([2.48337812e-13, 6.77950478e-13, 3.75366977e-13, 2.72137019e-13,
         2.14264592e-13, 2.75928259e-13]),
  'beta': array([1.34782581e-13, 1.24343031e-13, 9.89102994e-14, 1.05742442e-13,
         7.48115193e-14, 1.33001173e-13])},
 {'alpha': array([3.78469529e-13, 3.67933852e-13, 2.18187637e-13, 1.86777251e-13,
         2.07934355e-13, 1.47731823e-13]),
  'beta': array([9.31514164e-14, 1.20827868e-13, 9.87985777e-14, 8.85699293e-14,
         5.03750603e-14, 1.36442005e-13])},
 {'alpha': array([2.45359147e-13, 4.69100385e-13, 3.26722206e-13, 1.36640230e-13,
         1.75198865e-13, 1.76316139e-13]),
  'beta': array([1.51041597e-13, 1.20383891e-13, 1.39675029e-13, 1.10388505e-13,
         8.08144942e-14, 1.63075113e-13])},
 {'alpha': array([3.12167368e-13, 7.66114938e-13, 3.98726583e-13, 1.88803054e-13,
         2.75298972e-13, 2.21803391e-13]),
  'beta': array([8.25299896e-14, 9.88190782e-14, 8.53412660e-14, 7.62496905e-14,
         4.13787264e-14, 8.77171244e-14])},
 {'alpha': array([3.62971240e-13, 6.81229567e-13, 3.71774645e-13, 1.83927185e-13,
         2.49865826e-13, 3.61263270e-13]),
  'beta': array([1.42082336e-13, 2.09806868e-13, 1.53271412e-13, 9.34439982e-14,
         9.75470314e-14, 1.19750929e-13])},
 {'alpha': array([2.49074948e-13, 5.52168767e-13, 1.86328143e-13, 2.19485149e-13,
         1.77954335e-13, 2.60202436e-13]),
  'beta': array([1.27400987e-13, 1.13909762e-13, 1.38772003e-13, 8.58667939e-14,
         6.99167076e-14, 1.27551768e-13])},
 {'alpha': array([3.28154878e-13, 6.45110337e-13, 6.59793582e-13, 1.08425847e-13,
         2.39342362e-13, 2.32995420e-13]),
  'beta': array([1.14952254e-13, 1.26817160e-13, 1.51052919e-13, 7.98560744e-14,
         7.12602750e-14, 1.33606745e-13])},
 {'alpha': array([2.61589076e-13, 1.47877196e-12, 4.22049446e-13, 4.81729466e-13,
         3.31415461e-13, 3.51814490e-13]),
  'beta': array([1.30833086e-13, 1.44851060e-13, 1.43447882e-13, 9.46688221e-14,
         7.55675069e-14, 1.29017357e-13])},
 {'alpha': array([5.38295463e-13, 9.38453229e-13, 2.48680905e-13, 2.61379392e-13,
         3.62430725e-13, 1.79190943e-13]),
  'beta': array([1.34048767e-13, 7.45367844e-14, 8.94800225e-14, 7.79010649e-14,
         6.38126825e-14, 1.22019089e-13])},
 {'alpha': array([1.84813005e-13, 5.15069983e-13, 7.06027400e-13, 1.17973303e-13,
         1.71819750e-13, 1.59732476e-13]),
  'beta': array([1.32439799e-13, 9.73419254e-14, 1.32983250e-13, 1.15514790e-13,
         6.92882872e-14, 1.57071181e-13])},
 {'alpha': array([4.40683964e-13, 8.69667005e-13, 5.66029117e-13, 2.11992840e-13,
         2.76731960e-13, 1.92230840e-13]),
  'beta': array([1.78117025e-13, 1.68844123e-13, 2.11517237e-13, 1.25083592e-13,
         1.03525848e-13, 1.32510208e-13])},
 {'alpha': array([4.27295446e-13, 5.76932988e-13, 8.70079154e-13, 2.40903692e-13,
         3.29591074e-13, 2.15172515e-13]),
  'beta': array([1.44688729e-13, 1.33631673e-13, 1.46029959e-13, 8.24525261e-14,
         7.63254846e-14, 1.22995983e-13])},
 {'alpha': array([3.92980055e-13, 1.08807017e-12, 3.35448025e-13, 2.08175259e-13,
         3.14306988e-13, 2.04092160e-13]),
  'beta': array([1.40279941e-13, 1.21482454e-13, 1.01780221e-13, 8.60772667e-14,
         6.86436429e-14, 1.09615227e-13])},
 {'alpha': array([6.80614754e-13, 7.45385915e-13, 3.23599429e-13, 1.83128895e-13,
         3.61031547e-13, 2.95491412e-13]),
  'beta': array([1.51769080e-13, 1.24781872e-13, 1.14018499e-13, 8.13047214e-14,
         7.52627200e-14, 9.67261478e-14])},
 {'alpha': array([2.65645789e-13, 7.68991291e-13, 5.73379794e-13, 2.51043835e-13,
         2.38136971e-13, 1.26831815e-13]),
  'beta': array([1.03795124e-13, 1.02734988e-13, 1.12320686e-13, 8.89899035e-14,
         5.32516125e-14, 1.19562264e-13])},
 {'alpha': array([1.92180008e-13, 9.92849126e-13, 3.35985705e-13, 1.74109408e-13,
         2.19146232e-13, 1.18559703e-13]),
  'beta': array([1.04166288e-13, 9.84388603e-14, 1.37303994e-13, 8.55319620e-14,
         5.84441504e-14, 1.36668251e-13])},
 {'alpha': array([3.04663499e-13, 9.67814658e-13, 2.91510875e-13, 2.37306128e-13,
         2.78069253e-13, 2.04534690e-13]),
  'beta': array([1.84701199e-13, 9.74711417e-14, 9.78151712e-14, 1.23578703e-13,
         8.71927515e-14, 1.76073763e-13])},
 {'alpha': array([2.09893833e-13, 3.45134550e-13, 1.71587872e-13, 1.30942024e-13,
         1.39382411e-13, 1.56467510e-13]),
  'beta': array([5.81451353e-14, 9.68972554e-14, 8.09167169e-14, 6.49659616e-14,
         3.32937943e-14, 7.75505625e-14])},
 {'alpha': array([1.75239616e-13, 6.45061819e-13, 4.42574354e-13, 1.57211826e-13,
         1.88316171e-13, 1.33316887e-13]),
  'beta': array([9.17885570e-14, 9.92552363e-14, 1.27049757e-13, 6.28204793e-14,
         5.32062177e-14, 9.17638326e-14])},
 {'alpha': array([1.54971113e-13, 1.93852604e-13, 2.12755508e-13, 1.53633681e-13,
         1.04816867e-13, 1.80512832e-13]),
  'beta': array([1.22278518e-13, 9.71338026e-14, 1.34862185e-13, 8.86236659e-14,
         6.08263286e-14, 1.11198650e-13])},
 {'alpha': array([2.55322659e-13, 4.66471918e-13, 4.64637956e-13, 1.60402642e-13,
         1.78656276e-13, 2.07412732e-13]),
  'beta': array([1.69659870e-13, 1.65985008e-13, 1.86478403e-13, 9.20628119e-14,
         1.00235773e-13, 1.04895146e-13])},
 {'alpha': array([2.67271765e-13, 1.00083520e-12, 6.98890647e-13, 1.52211580e-13,
         2.67961726e-13, 2.77205404e-13]),
  'beta': array([9.29278215e-14, 1.28675140e-13, 1.41632738e-13, 8.10004903e-14,
         5.31214630e-14, 9.40895904e-14])},
 {'alpha': array([2.36264420e-13, 7.12677092e-13, 1.58252598e-12, 2.62489361e-13,
         3.04585672e-13, 2.34724460e-13]),
  'beta': array([1.04925002e-13, 1.45110824e-13, 1.56978179e-13, 9.70177409e-14,
         6.62883819e-14, 1.21006898e-13])},
 {'alpha': array([4.42025034e-13, 5.02019468e-13, 4.82380390e-13, 2.25740101e-13,
         2.73269330e-13, 2.00176567e-13]),
  'beta': array([1.09028066e-13, 1.25258603e-13, 1.32274040e-13, 7.58786659e-14,
         6.29329582e-14, 1.21994664e-13])},
 {'alpha': array([3.30289575e-13, 5.15716539e-13, 2.63680685e-13, 2.42760113e-13,
         1.94450384e-13, 2.06633890e-13]),
  'beta': array([1.56918440e-13, 1.39578662e-13, 1.01508593e-13, 1.07231834e-13,
         8.59027058e-14, 1.22558988e-13])},
 {'alpha': array([3.37232482e-13, 6.82117435e-13, 4.54716735e-13, 1.82296628e-13,
         2.74985484e-13, 2.11200109e-13]),
  'beta': array([1.08737491e-13, 1.67499790e-13, 1.43565526e-13, 9.25493449e-14,
         6.85938795e-14, 1.39639393e-13])},
 {'alpha': array([1.42951634e-13, 3.42804865e-13, 2.28332472e-13, 1.29122185e-13,
         1.09758366e-13, 1.05825237e-13]),
  'beta': array([1.26159870e-13, 1.16316079e-13, 1.29543963e-13, 6.88518301e-14,
         7.20379176e-14, 1.13986294e-13])},
 {'alpha': array([1.64242978e-13, 5.59815398e-13, 4.45724844e-13, 1.61390668e-13,
         1.64811224e-13, 9.74347927e-14]),
  'beta': array([1.15312674e-13, 1.51980172e-13, 1.49242077e-13, 8.36713971e-14,
         7.35385896e-14, 9.00129655e-14])},
 {'alpha': array([3.39338368e-13, 9.75863828e-13, 6.70597938e-13, 2.45560958e-13,
         3.06691442e-13, 4.29203704e-13]),
  'beta': array([1.08124542e-13, 1.31294773e-13, 1.16226023e-13, 8.43816053e-14,
         6.19594966e-14, 1.04209486e-13])},
 {'alpha': array([4.54818706e-13, 5.52905508e-13, 7.92319389e-13, 2.61535516e-13,
         3.52276519e-13, 2.60875204e-13]),
  'beta': array([1.51231660e-13, 1.86064836e-13, 2.31301106e-13, 9.79738287e-14,
         1.11801957e-13, 1.04905000e-13])},
 {'alpha': array([1.92711333e-13, 1.01163777e-12, 4.31425354e-13, 1.82931763e-13,
         2.08461120e-13, 3.14275642e-13]),
  'beta': array([1.33277397e-13, 1.00893482e-13, 1.06191924e-13, 8.76093294e-14,
         6.99707537e-14, 9.79987899e-14])},
 {'alpha': array([1.57167264e-13, 1.91200071e-13, 1.85316480e-13, 1.54150998e-13,
         9.80694770e-14, 1.48123049e-13]),
  'beta': array([9.73905930e-14, 1.24927629e-13, 1.29868658e-13, 9.01191529e-14,
         6.44363991e-14, 6.93478445e-14])},
 {'alpha': array([3.83578163e-13, 4.75953284e-13, 3.81353249e-13, 1.32418393e-13,
         2.38494947e-13, 1.99557931e-13]),
  'beta': array([1.50051118e-13, 1.63338806e-13, 1.38686034e-13, 8.98099898e-14,
         9.19006417e-14, 1.02476032e-13])},
 {'alpha': array([2.44479121e-13, 5.36865030e-13, 2.21068569e-13, 2.00750341e-13,
         1.87794681e-13, 1.34668277e-13]),
  'beta': array([9.43980786e-14, 1.14448268e-13, 1.59169044e-13, 6.68759635e-14,
         5.89440422e-14, 8.81147761e-14])},
 {'alpha': array([3.94827439e-13, 1.14793139e-12, 4.92540084e-13, 1.88536755e-13,
         2.94596729e-13, 2.39168581e-13]),
  'beta': array([1.74708323e-13, 1.69238385e-13, 1.59570807e-13, 1.13810883e-13,
         1.02826442e-13, 1.24184610e-13])},
 {'alpha': array([3.66655862e-13, 8.30815516e-13, 9.44660017e-13, 3.94819030e-13,
         3.37622777e-13, 3.47532755e-13]),
  'beta': array([1.72703778e-13, 1.34022120e-13, 1.63742030e-13, 1.20177059e-13,
         8.58190546e-14, 1.51516907e-13])},
 {'alpha': array([4.32554719e-13, 6.47444153e-13, 3.99492190e-13, 2.15546008e-13,
         3.10195593e-13, 2.29837830e-13]),
  'beta': array([1.35207726e-13, 2.06598649e-13, 1.42434295e-13, 1.18100976e-13,
         7.58766290e-14, 1.84068112e-13])},
 {'alpha': array([2.91377171e-13, 3.34218719e-13, 2.67920303e-13, 1.84511281e-13,
         1.79166402e-13, 1.65631517e-13]),
  'beta': array([1.11808909e-13, 1.39216301e-13, 9.28839592e-14, 7.62695315e-14,
         6.46209222e-14, 1.22481559e-13])},
 {'alpha': array([2.22919754e-13, 3.74457971e-13, 6.71945337e-13, 1.49427039e-13,
         1.89942151e-13, 1.13922043e-13]),
  'beta': array([1.24247991e-13, 1.77555370e-13, 1.29075199e-13, 9.01999511e-14,
         6.32463393e-14, 1.35142997e-13])},
 {'alpha': array([5.99472923e-13, 7.34433484e-13, 6.61301375e-13, 2.12669298e-13,
         3.73270704e-13, 4.34429517e-13]),
  'beta': array([1.22881582e-13, 1.88470589e-13, 1.72041687e-13, 1.00920557e-13,
         7.80797965e-14, 1.30585909e-13])},
 {'alpha': array([3.50218337e-13, 3.31020671e-13, 3.26108594e-13, 1.75029784e-13,
         1.75529214e-13, 1.78577354e-13]),
  'beta': array([1.09270282e-13, 6.95904698e-14, 1.08362860e-13, 2.45906919e-13,
         5.95604062e-14, 3.34040351e-13])},
 {'alpha': array([1.47709305e-13, 2.53068448e-13, 2.33191530e-13, 1.01612072e-13,
         1.09000905e-13, 1.15060760e-13]),
  'beta': array([1.07109612e-13, 1.07016450e-13, 1.24649509e-13, 8.11210224e-14,
         6.33523197e-14, 1.07323322e-13])},
 {'alpha': array([2.55502736e-13, 1.02484858e-12, 2.17169382e-13, 1.21639027e-13,
         2.16554911e-13, 1.83680682e-13]),
  'beta': array([1.31494866e-13, 1.12242371e-13, 1.84299538e-13, 9.76694731e-14,
         7.07945084e-14, 1.28329455e-13])},
 {'alpha': array([6.24498077e-13, 1.40591513e-12, 2.69588898e-13, 1.30670941e-13,
         4.07321503e-13, 3.78797607e-13]),
  'beta': array([1.72876113e-13, 1.43188347e-13, 1.19809812e-13, 6.21167317e-14,
         8.60966111e-14, 1.35842721e-13])},
 {'alpha': array([2.29017525e-13, 7.23292540e-13, 3.09620883e-13, 9.96397035e-14,
         1.84230249e-13, 1.31184661e-13]),
  'beta': array([1.08873793e-13, 1.18685622e-13, 1.11185227e-13, 1.02166141e-13,
         6.66291478e-14, 1.09088767e-13])},
 {'alpha': array([2.01938180e-13, 4.36132819e-13, 2.04282453e-13, 1.04868529e-13,
         1.37501216e-13, 1.87625006e-13]),
  'beta': array([1.11987136e-13, 1.42022428e-13, 1.34197287e-13, 1.07308903e-13,
         7.50731553e-14, 8.57896077e-14])},
 {'alpha': array([4.17385860e-13, 9.54272820e-13, 7.20385900e-13, 1.82323845e-13,
         3.17387783e-13, 2.28646439e-13]),
  'beta': array([2.44093619e-13, 1.73600996e-13, 1.34979568e-13, 1.09776062e-13,
         1.22573600e-13, 1.21083663e-13])},
 {'alpha': array([1.55679394e-13, 5.13189082e-13, 2.91766952e-13, 1.29681423e-13,
         1.38908687e-13, 9.75463877e-14]),
  'beta': array([8.96843354e-14, 9.61140514e-14, 1.21226670e-13, 8.10409100e-14,
         5.19571154e-14, 1.27576216e-13])},
 {'alpha': array([2.41122445e-13, 5.90288412e-13, 8.55970982e-13, 1.16403373e-13,
         1.70194566e-13, 1.77863409e-13]),
  'beta': array([1.29672005e-13, 1.25970640e-13, 1.21358304e-13, 7.77618964e-14,
         7.15903700e-14, 1.14186619e-13])},
 {'alpha': array([4.20607626e-13, 8.97786109e-13, 3.17383829e-13, 1.80455216e-13,
         2.66380185e-13, 1.81537665e-13]),
  'beta': array([1.04149998e-13, 8.26801502e-14, 1.42214805e-13, 7.21040113e-14,
         5.34962846e-14, 8.57949406e-14])},
 {'alpha': array([4.19433753e-13, 7.31872609e-13, 2.37758318e-13, 1.59210400e-13,
         2.89453572e-13, 1.93388346e-13]),
  'beta': array([1.13789536e-13, 1.51268635e-13, 1.51749678e-13, 8.85009020e-14,
         6.97480130e-14, 1.08411067e-13])},
 {'alpha': array([4.65264556e-13, 6.36831423e-13, 6.12788788e-13, 1.57635640e-13,
         2.61706534e-13, 2.31348640e-13]),
  'beta': array([1.30011760e-13, 1.25982828e-13, 1.22016950e-13, 7.46103669e-14,
         7.52202801e-14, 1.00504680e-13])},
 {'alpha': array([2.79632573e-13, 1.00473359e-12, 8.60140730e-13, 1.66899356e-13,
         2.79841176e-13, 1.80377862e-13]),
  'beta': array([1.18556602e-13, 1.51496395e-13, 1.42632899e-13, 6.77953544e-14,
         7.71369644e-14, 1.02855810e-13])},
 {'alpha': array([3.56232455e-13, 9.72975476e-13, 5.86099607e-13, 1.63570923e-13,
         2.36997964e-13, 1.69396990e-13]),
  'beta': array([1.10456023e-13, 1.65716044e-13, 1.81799663e-13, 8.70393856e-14,
         7.49339880e-14, 1.02855665e-13])},
 {'alpha': array([1.41851211e-13, 6.21638744e-13, 1.12924987e-12, 1.27907475e-13,
         1.31941405e-13, 1.89214464e-13]),
  'beta': array([1.54414346e-13, 1.30187309e-13, 2.32825726e-13, 9.51071373e-14,
         8.78751600e-14, 1.55543064e-13])},
 {'alpha': array([1.62698483e-13, 5.49493643e-13, 1.73915310e-13, 1.69540702e-13,
         1.49720479e-13, 2.11567615e-13]),
  'beta': array([1.02924099e-13, 1.31896988e-13, 8.39121795e-14, 8.70443062e-14,
         5.77145035e-14, 9.40700655e-14])},
 {'alpha': array([2.06034949e-13, 5.04754259e-13, 2.99778777e-13, 1.35440301e-13,
         1.68997636e-13, 1.86370638e-13]),
  'beta': array([1.33897951e-13, 1.24314980e-13, 1.44363049e-13, 8.14722652e-14,
         7.55994293e-14, 1.10733203e-13])},
 {'alpha': array([1.42640412e-13, 5.70822478e-13, 9.69426222e-13, 2.22364088e-13,
         1.80604496e-13, 1.80881615e-13]),
  'beta': array([9.68185219e-14, 1.32213369e-13, 1.33211949e-13, 6.54474974e-14,
         6.42679856e-14, 7.84160081e-14])},
 {'alpha': array([4.08263483e-13, 4.78078893e-13, 9.67070769e-13, 4.40755417e-13,
         3.06710310e-13, 4.07139277e-13]),
  'beta': array([1.02359013e-13, 1.37692495e-13, 1.46099300e-13, 9.32466795e-14,
         6.75409772e-14, 1.01434612e-13])},
 {'alpha': array([3.29314744e-13, 1.06762067e-12, 4.73275058e-13, 1.84345944e-13,
         3.15154578e-13, 2.01871967e-13]),
  'beta': array([9.37396922e-14, 1.19469888e-13, 1.09297726e-13, 7.53705577e-14,
         5.43292937e-14, 6.75660366e-14])},
 {'alpha': array([3.48839819e-13, 6.92656167e-13, 1.90467320e-13, 1.12570622e-13,
         2.25279880e-13, 2.53628332e-13]),
  'beta': array([9.39824282e-14, 1.05278296e-13, 7.87947664e-14, 5.19028623e-14,
         4.93927734e-14, 8.50472113e-14])},
 {'alpha': array([1.88475436e-13, 6.66919434e-13, 3.11890390e-13, 1.10039437e-13,
         1.66200518e-13, 1.44236891e-13]),
  'beta': array([1.13504713e-13, 1.37866148e-13, 1.54392797e-13, 7.23457188e-14,
         7.54571080e-14, 9.22011738e-14])},
 {'alpha': array([3.30588097e-13, 1.13076497e-12, 2.84431397e-13, 1.72091007e-13,
         2.61923493e-13, 1.87809603e-13]),
  'beta': array([1.07389007e-13, 9.55653863e-14, 1.19542429e-13, 7.80745866e-14,
         6.11660780e-14, 9.11951035e-14])},
 {'alpha': array([4.32866488e-13, 4.69955054e-13, 2.19492570e-13, 1.78923014e-13,
         2.35842090e-13, 2.30927948e-13]),
  'beta': array([1.52468365e-13, 1.17564314e-13, 9.07577034e-14, 1.07778459e-13,
         7.89891127e-14, 1.00482056e-13])},
 {'alpha': array([3.36704881e-13, 4.53485585e-13, 4.52789473e-13, 1.64472066e-13,
         2.12977836e-13, 1.53523180e-13]),
  'beta': array([1.47882776e-13, 1.18650277e-13, 1.13968479e-13, 8.73752603e-14,
         8.27972561e-14, 9.02970711e-14])},
 {'alpha': array([5.40710168e-13, 8.53684671e-13, 2.46003721e-13, 2.02706383e-13,
         3.52400283e-13, 2.61998419e-13]),
  'beta': array([1.06122287e-13, 2.00039975e-13, 1.27297936e-13, 7.37041204e-14,
         7.76988145e-14, 8.12419399e-14])},
 {'alpha': array([2.53685395e-13, 7.56379169e-13, 2.87588317e-13, 2.19903340e-13,
         2.29727950e-13, 1.88074302e-13]),
  'beta': array([1.13466456e-13, 1.05685632e-13, 1.37843093e-13, 9.33817980e-14,
         7.01350021e-14, 1.20500939e-13])},
 {'alpha': array([1.13081947e-12, 9.97361237e-13, 3.91397548e-13, 3.42806370e-13,
         5.72008299e-13, 3.12149982e-13]),
  'beta': array([1.25520876e-13, 1.29231708e-13, 1.47777155e-13, 7.74959112e-14,
         7.17691493e-14, 1.06831561e-13])},
 {'alpha': array([3.05311813e-13, 9.74037774e-13, 9.85185412e-13, 4.24754400e-13,
         2.80947783e-13, 4.08113585e-13]),
  'beta': array([1.90785814e-13, 1.45111614e-13, 1.51698122e-13, 1.01257641e-13,
         9.93948227e-14, 1.79804927e-13])},
 {'alpha': array([2.91256528e-13, 3.84898950e-13, 2.31374284e-13, 1.30326435e-13,
         1.54945636e-13, 1.12884505e-13]),
  'beta': array([1.04273492e-13, 1.22489756e-13, 1.43938402e-13, 8.52472972e-14,
         6.31921700e-14, 1.09401503e-13])},
 {'alpha': array([6.03663370e-13, 8.37687483e-13, 1.46154017e-12, 2.85012473e-13,
         4.17544972e-13, 2.03448300e-13]),
  'beta': array([1.70321334e-13, 1.48498225e-13, 1.72791094e-13, 1.12370513e-13,
         1.03229928e-13, 1.07578757e-13])},
 {'alpha': array([6.71370129e-13, 7.87288685e-13, 6.26146897e-13, 2.99073372e-13,
         4.42518899e-13, 2.84006728e-13]),
  'beta': array([1.84847662e-13, 1.49647680e-13, 1.44594321e-13, 1.21652942e-13,
         1.07461519e-13, 1.02828523e-13])},
 {'alpha': array([3.17095378e-13, 6.73530443e-13, 4.80136255e-13, 1.34787298e-13,
         2.49265272e-13, 2.03588343e-13]),
  'beta': array([1.53903270e-13, 1.48276344e-13, 1.19823488e-13, 1.01233331e-13,
         7.98172471e-14, 1.28084753e-13])},
 {'alpha': array([1.11281381e-12, 1.63108001e-12, 5.43791593e-13, 4.12140780e-13,
         7.15070363e-13, 3.95479709e-13]),
  'beta': array([2.03163267e-13, 1.43124532e-13, 1.18681184e-13, 1.13210104e-13,
         1.01637716e-13, 1.26365501e-13])},
 {'alpha': array([1.40071003e-13, 9.56062513e-13, 8.18352131e-13, 1.72889540e-13,
         1.89064887e-13, 1.12556117e-13]),
  'beta': array([1.17363499e-13, 1.35953560e-13, 1.58848759e-13, 8.44632639e-14,
         6.24889880e-14, 1.07964408e-13])},
 {'alpha': array([3.23797236e-13, 1.17734242e-12, 6.09563283e-13, 3.68718743e-13,
         3.46312668e-13, 3.03695114e-13]),
  'beta': array([8.93800546e-14, 9.58282116e-14, 1.08626676e-13, 9.19484570e-14,
         5.65463768e-14, 8.58792537e-14])}]

8. Preparació de dades per a classificació amb SVM¶

Aquí, preparem les característiques i les etiquetes per a ser utilitzades en un model de classificació SVM. Això inclou la normalització de les característiques i la conversió de les etiquetes a un format adequat per al model. (Matricial)

In [ ]:
import numpy as np
from sklearn.preprocessing import StandardScaler

# `features` és la llista de característiques
# i `labels` és la llista d'etiquetes.

# Convertir les característiques en una matriu
X = np.array([np.concatenate([feat['alpha'], feat['beta']]) for feat in features])

# Normalitzar les característiques
scaler = StandardScaler()
X_scaled = scaler.fit_transform(X)

# Mostrar X_scaled
X_scaled

# Extreure les etiquetes dels epochs
labels = epochs.events[:, -1]

# Mapejar els identificadors d'esdeveniments a etiquetes binàries (0 per a 'Left Hand', 1 per a 'Right Hand')
# Això depèn dels IDs d'esdeveniment específics que hem utilitzat per a 'Left Hand' i 'Right Hand'
label_map = {10: 0, 11: 1}
y = np.array([label_map[label] for label in labels])

# Mostrar y
y
Out[ ]:
array([0, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0,
       0, 1, 0, 0, 0, 1, 1, 0, 0, 1, 1, 1, 1, 0, 1, 1, 0, 1, 0, 0, 0, 0,
       1, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 0, 1,
       1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 0,
       1, 1, 1, 1, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0,
       1, 0, 1, 0, 1, 0, 1, 0, 1, 1])

9. Implementació i avaluació del classificador SVM¶

Finalment, implementem i avaluem un classificador SVM. Això inclou la divisió de les dades en conjunts d'entrenament i prova, l'entrenament del model, la realització de prediccions i l'avaluació de la seva precisió, mitjançant diverses mètriques com la matriu de confusió i l'informe de classificació. Aquesta secció culmina el flux de treball d'anàlisi de dades EEG.

In [ ]:
from sklearn.model_selection import train_test_split
from sklearn.svm import SVC
from sklearn.metrics import confusion_matrix, accuracy_score, classification_report, cohen_kappa_score

# Dividir les dades en conjunts d'entrenament i prova
X_train, X_test, y_train, y_test = train_test_split(X_scaled, y, test_size=0.2, random_state=42)

# Crear el model SVM
svm_model = SVC(kernel='linear')  # altres kernels: 'linear', 'poly', 'rbf', etc.

# Entrenar el model
svm_model.fit(X_train, y_train)

# Fer prediccions amb les dades de prova
y_pred = svm_model.predict(X_test)

# Calcular mètriques d'avaluació
accuracy = accuracy_score(y_test, y_pred)
conf_matrix = confusion_matrix(y_test, y_pred)
class_report = classification_report(y_test, y_pred)
kappa_score = cohen_kappa_score(y_test, y_pred)

# Mostrar els resultats
print("Exactitud (Accuracy):", accuracy)
print("Matrís de Confusió:\n", conf_matrix)
print("Informe de Classificació:\n", class_report)
print("Puntuació Kappa:", kappa_score)
Exactitud (Accuracy): 0.625
Matrís de Confusió:
 [[7 2]
 [7 8]]
Informe de Classificació:
               precision    recall  f1-score   support

           0       0.50      0.78      0.61         9
           1       0.80      0.53      0.64        15

    accuracy                           0.62        24
   macro avg       0.65      0.66      0.62        24
weighted avg       0.69      0.62      0.63        24

Puntuació Kappa: 0.28